package com.richfun.boot.common.util;

import java.io.UnsupportedEncodingException;
import java.util.Random;

/**
 * 字符串工具类
 * */
public class StrUtil {

	public final static String COMMON_STRING = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
	/**
	 * 生成随机字符串
	 * */
	public static String randomString(int strLength) {
		StringBuilder randomString = new StringBuilder("");
		for(int i = 0; i < strLength; i++) {
			int index = (int) Math.abs(COMMON_STRING.length() * Math.random());
			randomString.append(COMMON_STRING.charAt(index));
		}
		return randomString.toString();
	}
}
